<?php 

namespace app\App\validate;

use think\Validate;
use plugin\saiadmin\basic\BaseValidate;

class DeviceValidate extends BaseValidate {

    /**
     * 定义验证规则
     */
    protected $rule =   [
        'device_id' => 'require|length:1,60',
        'device_name' => 'require|length:1,60',
        'device_type' => 'require|length:1,30',
        'device_sub_type' => 'require|length:1,20',
        'hard_version' => 'require|length:1,20',
    ];

    /**
     * 定义错误信息
     */
    protected $message = [
        'device_id.require' => 'device.validate.device_id_require',
        'device_id.length' => 'device.validate.device_id_length',
        'device_name.require' => 'device.validate.device_name_require',
        'device_name.length' => 'device.validate.device_name_length',
        'device_type.require' => 'device.validate.device_type_require',
        'device_type.length' => 'device.validate.device_type_length',
        'device_sub_type.require' => 'device.validate.device_sub_type_require',
        'device_sub_type.length' => 'device.validate.device_sub_type_length',
        'hard_version.require' => 'device.validate.hard_version_require',
        'hard_version.length' => 'device.validate.hard_version_length',
    ];


    /**
     * 定义场景
     */
    protected $scene = [
        'add'=> [ 'device_id', 'device_name', 'device_type', 'device_sub_type' ],
        'update'=> [ 'device_id', 'device_name' ],
        'delete'=> [ 'device_id' ]
    ];

}
